var a = require("../../../../@babel/runtime/helpers/toConsumableArray"), t = getApp();

Page({
    data: {
        language: "",
        datas: [],
        page: 1,
        isLoadMore: !0,
        total_page: 0
    },
    onLoad: function(a) {
        this._getData();
    },
    onReady: function() {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : wx.showToast({
            title: "没有更多数据",
            icon: "none"
        });
    },
    onShareAppMessage: function() {},
    _getData: function() {
        var a = this, e = t.getNetAddresss("plugin.commission.api.commission.get-commission-list");
        e += "&commission_type=4", t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 == e.result && (a.setData({
                    datas: e.data.data,
                    total_page: e.data.last_page,
                    isLoadMore: !0,
                    page: e.data.current_page
                }), a.data.total_page || a.setData({
                    total_page: 0
                }));
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    },
    getMoreData: function() {
        var e = this, o = this, s = {};
        if (this.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            var i = this.data.page;
            i += 1, this.setData({
                page: i
            }), s.commission_type = 4, s.page = this.data.page;
            var n = t.getNetAddresss("plugin.commission.api.commission.get-commission-list");
            t._getNetWork({
                url: n,
                data: s,
                success: function(t) {
                    o.setData({
                        isLoadMore: !0
                    });
                    var s = t.data;
                    if (1 == s.result) {
                        var i = s.data.data, n = [].concat(a(o.data.datas), a(i));
                        o.setData({
                            datas: n,
                            isLoadMore: !0,
                            page: s.data.current_page
                        });
                    } else {
                        var g = e.data.page;
                        g -= 1, o.setData({
                            page: g,
                            isLoadMore: !1
                        }), wx.showToast({
                            icon: "none",
                            title: s.msg,
                            duration: 1500
                        });
                    }
                }
            });
        }
    }
});